package com.youkeda.redpacket.service.impl;

import com.youkeda.redpacket.dao.UserDAO;
import com.youkeda.redpacket.dataobject.UserDO;
import com.youkeda.redpacket.model.User;
import com.youkeda.redpacket.params.UserInfoQueryParam;
import com.youkeda.redpacket.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 刘正星
 * @version 1.0.0
 * @ClassName UserServiceImpl.java
 * @Description TODO
 * @createTime 2020年09月30日 14:31:00
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDAO userDAO;

    @Override
    public List<User> query(UserInfoQueryParam param) {
        if (param == null){
            return null;
        }

        List<UserDO> userDOS = userDAO.selectByIds(param.getIds());
        List<User> users = userDOS.stream().map(userDO -> userDO.convertTOModel()).collect(Collectors.toList());
        return users;
    }

    @Override
    public Integer save(User user) {
        return null;
    }
}
